/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package inet.controller;

import static inet.constant.City.cities;
import static inet.constant.Countries.countries;
import static inet.constant.EQ.EQ;
import static inet.constant.Month.month;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author ÂuNgọcThái
 */
@ManagedBean
@SessionScoped
public class ConstantsController {

    /**
     * Creates a new instance of ConstantsController
     */
    private List<String> lstCity;
    private List<String> lstCountries;
    private List<String> lstEQ;
    private List<String> lstmonth;

    public ConstantsController() {
        lstCity = new LinkedList<String>();
        lstCountries = new LinkedList<String>();
        lstEQ = new LinkedList<String>();
        lstmonth = new LinkedList<String>();
    }

    public List<String> getLstmonth() {
        return lstmonth;
    }

    public void setLstmonth(List<String> lstmonth) {
        this.lstmonth = lstmonth;
    }

    public List<String> getLstEQ() {
        return lstEQ;
    }

    public void setLstEQ(List<String> lstEQ) {
        this.lstEQ = lstEQ;
    }

    public List<String> getLstCity() {
        return lstCity;
    }

    public void setLstCity(List<String> lstCity) {
        this.lstCity = lstCity;
    }

    public List<String> getLstCountries() {
        return lstCountries;
    }

    public void setLstCountries(List<String> lstCountries) {
        this.lstCountries = lstCountries;
    }

    public List<String> getCity() {
        int i = 0;
        while (i < cities.size() - 1) {
            i++;
            lstCity.add(cities.get(i));
        }
        return lstCity;
    }

    public List<String> getCountries() {
        int i = 0;
        while (i < countries.size() - 1) {
            i++;
            lstCountries.add(countries.get(i));
        }
        return lstCountries;
    }

    public List<String> getEQ() {
        int i = 0;
        while (i < EQ.size() - 1) {
            i++;
            lstEQ.add(EQ.get(i));
        }
        return lstEQ;
    }
      public String noteDate() {
        DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
        Date date = new Date();
        return dateFormat.format(date);
    }
     public List<String> getMonth() {
        int i = 0;
        
        while (i < countDateOfMonth()) {
            i++;
            lstmonth.add(month.get(i));
        }
        return lstmonth;
    }
     public int countDateOfMonth() {
        int day=31;
        SimpleDateFormat sd = new SimpleDateFormat("MM/yyyy");
        try {
            Date d = sd.parse(noteDate());
            Calendar c = Calendar.getInstance();
            c.setTime(d);
            day =c.getActualMaximum(Calendar.DAY_OF_MONTH);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return day;
    }
}
